2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_PAINTELEMENT_JUCEHEADER__
27 #define __JUCER_PAINTELEMENT_JUCEHEADER__
29 #include "../jucer_GeneratedCode.h"
33 class ElementSiblingComponent
;
36 //==============================================================================
38 Base class for objects that can be used in a PaintRoutine.
41 class PaintElement
: public Component
,
42 public ChangeListener
,
43 public ComponentBoundsConstrainer
46 //==============================================================================
47 PaintElement (PaintRoutine
* owner
, const String
& typeName
);
48 virtual ~PaintElement();
50 //==============================================================================
51 virtual void setInitialBounds (int parentWidth
, int parentHeight
);
53 virtual const Rectangle
<int> getCurrentBounds (const Rectangle
<int>& activeArea
) const;
54 virtual void setCurrentBounds (const Rectangle
<int>& newBounds
, const Rectangle
<int>& activeArea
, const bool undoable
);
56 const RelativePositionedRectangle
& getPosition() const;
57 void setPosition (const RelativePositionedRectangle
& newPosition
, const bool undoable
);
59 void updateBounds (const Rectangle
<int>& activeArea
);
61 const String
& getTypeName() const throw() { return typeName
; }
62 PaintRoutine
* getOwner() const throw() { return owner
; }
64 //==============================================================================
65 virtual void draw (Graphics
& g
,
66 const ComponentLayout
* layout
,
67 const Rectangle
<int>& parentArea
) = 0;
69 virtual void drawExtraEditorGraphics (Graphics
& g
, const Rectangle
<int>& relativeTo
);
71 virtual void getEditableProperties (Array
<PropertyComponent
*>& properties
);
73 virtual void showPopupMenu();
75 //==============================================================================
76 virtual XmlElement
* createXml() const = 0;
77 virtual bool loadFromXml (const XmlElement
& xml
) = 0;
79 //==============================================================================
80 virtual void fillInGeneratedCode (GeneratedCode
& code
, String
& paintMethodCode
) = 0;
82 JucerDocument
* getDocument() const;
84 virtual void changed();
85 bool perform (UndoableAction
* action
, const String
& actionName
);
87 //==============================================================================
88 void paint (Graphics
& g
);
90 void mouseDown (const MouseEvent
& e
);
91 void mouseDrag (const MouseEvent
& e
);
92 void mouseUp (const MouseEvent
& e
);
93 void changeListenerCallback (ChangeBroadcaster
*);
94 void parentHierarchyChanged();
99 PaintRoutine
* const owner
;
100 RelativePositionedRectangle position
;
104 void checkBounds (Rectangle
<int>& bounds
,
105 const Rectangle
<int>& previousBounds
,
106 const Rectangle
<int>& limits
,
107 bool isStretchingTop
,
108 bool isStretchingLeft
,
109 bool isStretchingBottom
,
110 bool isStretchingRight
);
112 void applyBoundsToComponent (Component
* component
, const Rectangle
<int>& bounds
);
114 const Rectangle
<int> getCurrentAbsoluteBounds() const;
115 void getCurrentAbsoluteBoundsDouble (double& x
, double& y
, double& w
, double& h
) const;
117 virtual void selectionChanged (const bool isSelected
);
119 virtual void createSiblingComponents();
121 void siblingComponentsChanged();
123 OwnedArray
<ElementSiblingComponent
> siblingComponents
;
125 void updateSiblingComps();
128 ResizableBorderComponent
* border
;
130 bool selected
, dragging
, mouseDownSelectStatus
;
131 double originalAspectRatio
;
132 ChangeBroadcaster selfChangeListenerList
;
136 #endif // __JUCER_PAINTELEMENT_JUCEHEADER__